
package com.controller.common;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Service;

@Service
@Aspect
public class MyAspectJ {

	@After("execution(* com.controller.services.impl.*.*(..))&&" + "args(id,..)")
	public void logafter(Integer id) {

		System.out.println("千方集团logafter ************后方法名：" + id);
	}

	@Before("execution(* com.controller.services.impl.*.*(..))&&" + "args(id,..)")
	public void logAfter(Integer id) {

		System.out.println("logAfter********** 后方法名：" + id);
	}

	// 环绕通知（在"前通知"之后）
	@Around("execution(* com.apjept.bean.chapter..*.*(..))&&" + "args(name,..)")
	public Object logAround(ProceedingJoinPoint pjp, String name) throws Throwable {

		// start stopwatch
		System.out.println("logPerson 环绕通知 start stopwatch 方法名：" + pjp.getSignature().getName());
		Object retVal = pjp.proceed();
		// stop stopwatch
		System.out.println("logPerson 环绕通知 stop stopwatch 方法名：" + pjp.getSignature().getName() + " return: " + retVal.toString());

		return retVal;
	}

	@AfterThrowing("execution(* com.apjept.bean.chapter..*.MyMethodThrow())")
	public void afterThrowAdvice() {

	}
}
